﻿using System.Collections.Generic;
using System.Linq;
using Kratos.Framework.ContentManagement.Models.SystemRights;

namespace Kratos.Framework.Modules.Core.Repositories
{
    public static class MenuPermissionRepositoryExtensions
    {
        /// <summary>
        /// 根据父Id获取菜单
        /// </summary>
        public static IEnumerable<MenuPermission> GetRootMenu(this IQueryable<MenuPermission> source, int parentId)
        {
            return source.Where(mp => mp.ParentId == parentId);
        }

        public static IEnumerable<MenuPermission> GetMenusByLevel(this IQueryable<MenuPermission> source, int level)
        {
            return source.Where(mp => mp.NodeLevel == level);
        }
    }
}
